<?php
namespace script;
use script\Decorator_I;

class DecoratorBase
{
    /**
     * 添加观察者
     */
    private $objs = [];
    public function add(Decorator_I $obj)
    {
        $this->objs[] = $obj;
    }
    /**
     * 函数执行之前的装饰器
     */
    public function befer()
    {
        foreach ($this->objs as $value) {
            $value->befer();
        }
    }
    /**
     * 函数执行之后的装饰器
     */
    public function after()
    {
        $objs = array_reverse($this->objs);
        foreach ($objs as $value) {
            $value->after();
        }
    }
}